
<link rel="stylesheet" type="text/css" href="<?php echo $this->baseurl('/addons/swfuploaders/css/default.css');?>" media="all" />

<script type="text/javascript">
    var uploadAllFiles, uploadOnlyImageFiles;

    window.onload = function() {
        uploadAllFiles = new SWFUpload({
            // Backend Settings
            upload_url: "<?php echo $this->baseurl('/common/general_upload/'); ?>",
            post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},

            // File Upload Settings
            file_size_limit : "102400",	// 100MB
            file_types : "*.*",
            file_types_description : "All Files",
            file_upload_limit : "100",
            file_queue_limit : "0",

            // Event Handler Settings (all my handlers are in the Handler.js file)
            file_dialog_start_handler : fileDialogStart,
            file_queued_handler : fileQueued,
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_start_handler : uploadStart,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : uploadSuccess,
            upload_complete_handler : uploadComplete,

            // Button Settings
            button_image_url : "<?php echo $this->baseurl('/addons/swfuploaders/XPButtonUploadText_61x22.png'); ?>",
            button_placeholder_id : "spanButtonPlaceholder1",
            button_width: 61,
            button_height: 22,
            
            // Flash Settings
            flash_url : "<?php echo $this->baseurl('/addons/swfuploaders/swfupload/swfupload.swf'); ?>",
            

            custom_settings : {
                progressTarget : "fsUploadProgress1",
                cancelButtonId : "btnCancel1"
            },
            
            // Debug Settings
            debug: false
        });

        uploadOnlyImageFiles = new SWFUpload({
            // Backend Settings
            upload_url: "<?php echo $this->baseurl('/common/general_upload/'); ?>",
            post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},

            // File Upload Settings
            file_size_limit : "102400",	// 100MB
            file_types : "*.jpg;*.gif;*.png",
            file_types_description : "Image Files",
            file_upload_limit : "100",
            file_queue_limit : "100",

            // Event Handler Settings (all my handlers are in the Handler.js file)
            file_dialog_start_handler : fileDialogStart,
            file_queued_handler : fileQueued,
            file_queue_error_handler : fileQueueError,
            file_dialog_complete_handler : fileDialogComplete,
            upload_start_handler : uploadStart,
            upload_progress_handler : uploadProgress,
            upload_error_handler : uploadError,
            upload_success_handler : uploadSuccess,
            upload_complete_handler : uploadComplete,

            // Button Settings
            button_image_url : "<?php echo $this->baseurl('/addons/swfuploaders/XPButtonUploadText_61x22.png'); ?>",
            button_placeholder_id : "spanButtonPlaceholder2",
            button_width: 61,
            button_height: 22,
            
            // Flash Settings
            flash_url : "<?php echo $this->baseurl('/addons/swfuploaders/swfupload/swfupload.swf'); ?>",

            swfupload_element_id : "flashUI2",		// Setting from graceful degradation plugin
            degraded_element_id : "degradedUI2",	// Setting from graceful degradation plugin

            custom_settings : {
                progressTarget : "fsUploadProgress2",
                cancelButtonId : "btnCancel2"
            },

            // Debug Settings
            debug: false
        });

     }


    window.addEvent("domready", function() {
        $$(".upload").addEvent("click", function(e){
            if( $("hidden_content").getStyle("display") == 'none')
            {
                $("hidden_content").setStyle("display", "block");
            }
            else
            {
                
                $("hidden_content").setStyle("display", "none");          
            }
        });	
    });
</script>
<div style="background-color:#D9E5EE;padding-top:20px;">
    <div class="displaynone" id="hidden_content">
        <table border="0" align="center" width="100%">
            <tr>
                <td align="center">
                    <div class="app_box">
                        <h3 class="app_box_title">All file format allowed</h3>
                        <div class="box-body innter">
                            <p>
                                <div class="fieldset flash" id="fsUploadProgress1"></div>
                                <span id="spanButtonPlaceholder1"></span>
                                <input id="btnCancel1" type="button" value="Cancel Uploads" onclick="cancelQueue(uploadAllFiles);" disabled="disabled" class="simple_button" />
                                 <?php echo App::Load("Helper/Html")->linkTag($this->baseurl("/admin/filemanager"),"Refresh"); ?>
                            </p>
                        </div>
                     </div>
                </td>
                <td align="center">
                    <div class="app_box">
                        <h3 class="app_box_title">Only Image files are allowed</h3>
                        <div class="box-body innter">
                                <div class="fieldset flash" id="fsUploadProgress2"></div>
                                <span id="spanButtonPlaceholder2"></span>
                                <input id="btnCancel2" type="button" value="Cancel Uploads" onclick="cancelQueue(uploadOnlyImageFiles);" disabled="disabled" class="simple_button" />
                                <?php echo App::Load("Helper/Html")->linkTag($this->baseurl("/admin/filemanager"),"Refresh"); ?>
                        </div>
                     </div>
                </td>
            </tr>
        </table>
    </div>
<?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back'),array('type'=>'upload')) ,"title" => "File Manager")); ?>
<?php 
    if( !empty($file_list['data'])):
        foreach( $file_list['data'] as $key => $val ):
        
            $file_path = $this->get_config("filemanager_path") . "/{$val['name']}";
            
            if( App::Load("Helper/Utility")->is_image( $val['name'] )):
                $img_path = $this->get_config("filemanager_path") . "/{$val['name']}";      
            else:
                $img_path = $this->basedir("/images/admin/file.gif");      
            endif;
                   
            if( App::Load("Helper/Utility")->is_image( $val['name'] )):
                $optimizepath = App::Load("Helper/Html")->inputTag("file",$this->baseurl('/common/get_image/' . base64_encode( $file_path) . '/50/fix'),array("class"=>"app_input"));
            else:
                $optimizepath = App::Load("Helper/Html")->inputTag("file",$this->baseurl('/common/download/' . base64_encode( $file_path)),array("class"=>"app_input"));
            endif;
                      
            App::Module('DataGrid')->addRow(App::Load("Helper/Html")->linkTag($this->baseurl('/common/download/' . base64_encode( $file_path)),App::Load("Helper/Html")->imgDTag($img_path,"/50/fix")),
                            App::Load("Helper/Html")->inputTag("filename",$val['name'],array("class"=>"app_input")),
                            App::Load("Helper/Html")->inputTag("filepath",$this->baseurl('/common/get_image/' . base64_encode( $file_path) . '/50/fix'),array("class"=>"app_input")),
                            $optimizepath,
                            App::Load("Helper/Html")->linkTag($this->baseurl('/admin/filemanager/delete/' . base64_encode( $val['name'])),App::Load("Helper/Html")->imgTag($this->baseurl('/images/admin/remove.gif')))
                        );                       
        endforeach;
            
            App::Module('DataGrid')->setHeader(array('Download','File Name', 'Link', 'Optimized Link','Options'))
                                   ->setFooter($file_list['link'] . " " . $file_list['paging'] . " &nbsp;&nbsp; Total Entry : " . $file_list["total"])
                                   ->Render();
            /*
           echo $this->callElement(
                                   'default/tools/table_listing', 
                                   array(
                                               't_head' => array('Download','File Name', 'Link', 'Optimized Link','Options'),
                                               'listing_data' => $data, 
                                               'link' => $file_list['link'] . " " . $file_list['paging'] . " &nbsp;&nbsp; Total Entry : " . $file_list["total"])
                                   );
            */
    endif;
?>
<?php echo $this->callElement("default/tools/tool_bar",array("buttons"=>array( array('type'=>'back')) ,"position" => 'bottom')); ?>
</div>